# -*- coding:utf-8 -*-
import RPi.GPIO as io
import time

infra_left  = 14
infra_right = 15

io.setmode(io.BCM)
io.setup(infra_left, io.IN, pull_up_down=io.PUD_DOWN)
io.setup(infra_right, io.IN, pull_up_down=io.PUD_DOWN)

count = 0
while False:
    #LOW是白色，HIGH是黑色
    if io.input(infra_left) == io.LOW:
        print('low')
    elif io.input(infra_left) == io.HIGH:
        print('high')
    count += 1
    if (count> 50):
        break
    time.sleep(0.5)

def test(pin):
    print('检测到rising', pin)

def test2(pin):
    print('...检测到falling', pin)

io.add_event_detect(infra_left, io.RISING, callback=test, bouncetime=100)
# io.add_event_detect(infra_left, io.FALLING, callback=test2, bouncetime=100)


for _ in range(15):
    print('保持等待。。。')
    time.sleep(5)

io.cleanup()